<div>
  <el-breadcrumb class="bread" separator-class="el-icon-arrow-right">
    <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
    <el-breadcrumb-item>权限管理</el-breadcrumb-item>
    <el-breadcrumb-item>权限列表</el-breadcrumb-item>
  </el-breadcrumb>

  <!-- 表格 -->
  <el-table :data="rolesList" style="width: 100%">
    <el-table-column type="expand">
      <template slot-scope="scope">
        <!-- 一级权限 -->
        <el-row
          v-for="item1 in scope.row.children"
          :key="item1.id"
          class="item1"
        >
          <el-col :span="4">
            <el-tag closable type="primary">{{ item1.authName }}</el-tag>
            <i class="el-icon-arrow-right"></i>
          </el-col>
          <el-col :span="20">
            <!-- 二级权限 -->
            <el-row
              v-for="item2 in item1.children"
              :key="item2.id"
              class="item2"
            >
              <el-col :span="4">
                <el-tag closable type="success">{{ item2.authName }}</el-tag>
                <i class="el-icon-arrow-right"></i>
              </el-col>
              <el-col :span="20">
                <!-- 三级权限 -->
                <el-tag
                  closable
                  type="warning"
                  v-for="item3 in item2.children"
                  :key="item3.id"
                  class="item3"
                  >{{ item3.authName }}</el-tag
                >
              </el-col>
            </el-row>
          </el-col>
        </el-row>
      </template>
    </el-table-column>
    <el-table-column width="80px" type="index" :index="indexMethod">
    </el-table-column>
    <el-table-column prop="roleName" label="角色名称" width="180">
    </el-table-column>
    <el-table-column prop="roleDesc" label="描述" width="180">
    </el-table-column>
    <el-table-column prop="add" label="操作">
      <template slot-scope="scope">
        <el-button
          size="mini"
          plain
          type="primary"
          icon="el-icon-edit"
        ></el-button>
        <el-button
          size="mini"
          plain
          type="danger"
          icon="el-icon-delete"
        ></el-button>
        <el-button
          size="mini"
          @click="showRolesDialog(scope.row)"
          plain
          type="success"
          icon="el-icon-check"
          >分配权限</el-button
        >
      </template>
    </el-table-column>
  </el-table>

  <!-- 分配列表树形结构对话框 -->
  <el-dialog title="角色授权" :visible.sync="dialogRolesVisible">
    <!-- 树 -->
    <!--
      :data : 动态绑定数据
       show-checkbox 显示多选框
       node-key="id" : 使用数据中哪个属性来作为每隔节点的key值,一般就是唯一的id值
        :default-expanded-keys="[2, 3]"  默认展开想id=2 id=3
         :default-checked-keys="[5]"   默认选中
           :props="defaultProps" 默认识别
             默认识别 chilren作为子节点  label 作为节点名

     -->
    <el-tree
      :data="rightsTree"
      show-checkbox
      node-key="id"
      :default-expanded-keys="[2, 3]"
      :default-checked-keys="[5]"
      :props="defaultProps"
      :default-expand-all="true"
      ref="tree"
    >
    </el-tree>

    <div slot="footer" class="dialog-footer">
      <el-button @click="dialogRolesVisible = false">取 消</el-button>
      <el-button type="primary" @click="assignRights">确 定</el-button>
    </div>
  </el-dialog>
</div>
